<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.2</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8"/>
    <link rel="stylesheet" href="../../css/font.css">
    <link rel="stylesheet" href="../../css/xadmin.css">
    <link rel="stylesheet" href="../layui/css/layui.css">
    <link rel="stylesheet" href="../../css/layui.mobile.css">
    <script type="text/javascript" src="../../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../../js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form" lay-filter="itemAdd">
            <div class="layui-form-item">
                <strong style="font-size: 20px">项目基础信息</strong>
            </div>
            <div class="layui-form-item">

                <label class="layui-form-label">
                    *项目名
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="drName" id="drName" lay-verify="required" placeholder="" autocomplete="off"
                           class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">药品编码</label>
                <div class="layui-input-inline">
                    <input type="text" name="drCode" id="drCode" lay-verify="required" placeholder="" autocomplete="off"
                           class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    药品类型</label>
                <div class="layui-input-inline">
                    <select name="drType" id="drType" lay-verify="required" lay-search="">
                        <option value="">无</option>
                        <option value="1">饮片</option>
                        <option value="2">颗粒</option>
                        <option value="3">袋装颗粒</option>
                    </select>
                </div>
            </div>


            <div class="layui-form-item">
                <label class="layui-form-label">*调理方类型</label>
                <div class="layui-input-inline">
                    <select name="drRecuperationType" id="drRecuperationType" lay-search=""
                            lay-filter="drRecuperationType">
                        <option value="">调理方类型</option>
                        <option value="29">中药</option>
                        <option value="30">西药</option>
                        <option value="31">中成药</option>
                    </select>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">包装规格</label>
                <div class="layui-input-inline">
                    <input type="text" name="drSpecs" id="drSpecs" lay-verify="required" placeholder=""
                           autocomplete="off"
                           class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">药物生产日期</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input test-item" id="drManufactureDate" placeholder="药物生产日期">
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">药品有效期</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input test-item" id="drValidityDate" placeholder="药物生产日期">
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    药品频次</label>
                <div class="layui-input-inline">

                    <div class="layui-input-inline">
                        <input type="text" name="drFrequency" id="drFrequency" lay-verify="required" placeholder=""
                               autocomplete="off"
                               class="layui-input">
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"> 用法</label>
                <div class="layui-input-inline layui-form">
                    <select name="drUsage" id="drUsage" lay-verify="required" lay-search="">
                        <option value="">请选择</option>

                    </select>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">药品生产厂家
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="drFactory" id="drFactory" lay-verify="required" placeholder=""
                           autocomplete="off"
                           class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><i class="layui-icon layui-icon-tips"
                                                   style="font-size: 15px; color:&#xe607;"
                                                   title="单位为<药品>在药房储存的单位。也是药品的销售单位、医生的开方单位。"></i>*单位</label>
                <div class="layui-input-inline">
                    <select name="drUnit" id="drUnit" lay-verify="required" lay-search="">
                        <option value="1">克</option>
                        <option value="2">千克</option>
                        <option value="3">包</option>
                        <option value="4">盒</option>
                        <option value="5">袋</option>
                        <option value="6">支</option>
                        <option value="7">次</option>
                        <option value="8">片</option>
                        <option value="9">疗程</option>
                    </select>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">药品备注</label>
                <div class="layui-input-inline">
                    <input type="text" name="drRemarks" id="drRemarks" lay-verify="required" placeholder=""
                           autocomplete="off"
                           class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">药品售价</label>
                <div class="layui-input-inline">
                    <input type="text" name="drPriceSales" id="drPriceSales" lay-verify="required" placeholder=""
                           autocomplete="off"
                           class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">每天用量
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="drConsumptionDay" id="drConsumptionDay" lay-verify="required"
                           placeholder="" autocomplete="off"
                           class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">每次用量
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="drConsumptionTimes" id="drConsumptionTimes" lay-verify="required"
                           placeholder="" autocomplete="off"
                           class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">原产地
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="drProducingArea" id="drProducingArea" lay-verify="required" placeholder=""
                           autocomplete="off"
                           class="layui-input">
                </div>
            </div>

            <!-- <div class="layui-form-item">
                 <label class="layui-form-label"><i class="layui-icon layui-icon-tips"
                                                    style="font-size: 15px; color:&#xe607;" title="设定后，收费时以此类型打折"></i>
                     收费类型</label>
                 <div class="layui-input-inline">
                     <select name="Item_type" lay-verify="required" lay-search="">
                         <option value="">无</option>
                         <option value="1">诊疗费</option>
                         <option value="2">西药费</option>
                         <option value="3">中药费</option>
                     </select>
                 </div>
             </div>-->

            <!--<div class="layui-form-item">
                <strong style="font-size: 20px">其他信息</strong>
            </div>-->

            <!--   <div class="layui-form-item">
                   <tr>
                       <th>01.收费项目新增时，请务必准确填写相关内容信息；否则可能导致添加项目无效；</th>
                       <br/>
                       <th>02.收费类型代指此项目属于何种折扣类型，设定后将可在缴费时选择设置；</th>
                       <br/>
                       <th>03.仓库单位为“仓库”的储存单位及进货单位，销售单位为“医生的开方单位及药房”的存储单位；库存转换率则为“库存单位/销售单位=库存转换率”；</th>
                       <br/>
                       <th>04.中药品信息为中药药品必填项(所属方型需为“中药”)；</th>
                       <br/>
                       <th>05.药品编码为中药颗粒类药品在连接“颗粒配药机”时所需填写的项目；</th>
                       <br/>
                       <th>06.“当量转换比”及“对应饮片药品”为中药非饮片类型药品与饮片药品互相转换时填写的项目；“单位饮片/单位非饮片类型药品=当量转换比”；(当量转换按“项目名称”或“别名”进行匹配)</th>
                       <br/>
                       <th>07.“最大用量”、“默认煎法”“默认用法”“药柜号”均为辅助信息，前三项为辅助医生开方，后一项为辅助药房取药；</th>
                       <br/>
                       <th>08.包装信息中，“包装含量”应填写数值，例：“一套”针灸套餐中，包含“X次”针灸治疗；则包装含量为“X”；</th>
                       <br/>
                       <th>09.“是否附加费”，当“所属方型”为“其他”时，可选用；选用后，则该项目可在中药处方开具时以附加费的形式选用；</th>
                       <br/>
                   </tr>
               </div>-->

            <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <button type="button" class="layui-btn" lay-filter="add" lay-submit="" id="LAY-component-form-getval">
                    增加
                </button>
            </div>
        </form>

    </div>
</div>
<script>


    layui.use(['form', 'layer', 'jquery', 'laydate'], function () {

        var form = layui.form,
            laydate = layui.laydate,
            layer = layui.layer,
            $ = layui.jquery;
        //自定义格式

        lay('.test-item').each(function () {
            laydate.render({
                elem: this
                , format: 'yyyy-MM-dd'
                , type: 'datetime'
                , trigger: 'click'
            });
        });


        function getClassify() {
            $.ajax({
                url: '/JT90/usage/selectUsageList',
                success: function (map) {
                    if (map.msg) {
                        for (var i = 0; i < map.data.length; i++) {
                            if (map.data[i].usageState===15){
                                $("#drUsage").append("<option value=\"" + map.data[i].usageId + "\">" + map.data[i].usageName + "</option>");
                            }
                        }
                        //重新渲染
                        form.render("select");
                    }
                }
            });
        }


        getClassify();

        //监听提交
        form.on('submit(add)', function (data) {
            //发异步，把数据提交给php
            var
                drName = $('#drName').val(),
                drCode = $('#drCode').val(),
                drType = $('#drType').val(),
                drRecuperationType = $('#drRecuperationType').val(),
                drSpecs = $('#drSpecs').val(),
                drManufactureDate = $('#drManufactureDate').val(),
                drValidityDate = $('#drValidityDate').val(),
                drFrequency = $('#drFrequency').val(),
                drUsage = $('#drUsage').val(),
                drFactory = $('#drFactory').val(),
                drUnit = $('#drUnit').val(),
                drRemarks = $('#drRemarks').val(),
                drPriceSales = $('#drPriceSales').val(),
                drConsumptionDay = $('#drConsumptionDay').val(),
                drConsumptionTimes = $('#drConsumptionTimes').val(),
                drProducingArea = $('#drProducingArea').val();
            console.log(drName + '--' + drCode + '--' + drType + '--' + drRecuperationType + '--' + drSpecs + '--' + drManufactureDate + '--' + drValidityDate + '--' + drFrequency + '--' + drUsage + '--' + drFactory + '--' + drUnit + '--' + drRemarks + '--' + drPriceSales + '--' + drConsumptionDay + '--' + drProducingArea);
            $.ajax({
                url: '/JT90/items/insertItem',//地址
                dataType: 'json',//数据类型
                data: {
                    "drName": drName,
                    "drCode": drCode,
                    "drType": drType,
                    "drRecuperationType": drRecuperationType,
                    "drSpecs": drSpecs,
                    "drManufactureDate": drManufactureDate,
                    "drValidityDate": drValidityDate,
                    "drFrequency": drFrequency,
                    "drUsage": drUsage,
                    "drFactory": drFactory,
                    "drUnit": drUnit,
                    "drRemarks": drRemarks,
                    "drPriceSales": drPriceSales,
                    "drConsumptionTimes": drConsumptionTimes,
                    "drConsumptionDay": drConsumptionDay,
                    "drProducingArea": drProducingArea
                },
                type: 'GET',//类型
                contentType: 'application/json;charset=UTF-8',
                //请求成功
                success: function (map) {
                    if (map.msg) {

                        layer.alert("增加成功", {
                                icon: 6
                            },
                            function () {
                                //关闭当前frame
                                xadmin.close();

                                // 可以对父窗口进行刷新
                                xadmin.father_reload();
                            });

                    }
                    return false;
                },
                //失败/超时
                error: function () {
                    alert('請求超時');
                    //alert(errorThrown);
                }
            });
        });

    });


</script>
</body>

</html>